package com.dynamic.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.dynamic.pojo.User;
import com.dynamic.service.UserService;

@Controller
@RequestMapping("/user")
public class IndexController {
	@Resource
	private UserService userService;
	
	@RequestMapping("/showUser")
	public ModelAndView toIndex(HttpServletRequest request,Model model){
		System.out.println("123----"+(request.getParameter("id")));
		int userId = Integer.parseInt(request.getParameter("id"));
		User user = this.userService.getTest1UserById(userId);
		model.addAttribute("user", user);
		ModelAndView   mv = new ModelAndView();
		mv.addObject(user);
		mv.setViewName("showUser");
		return  mv;
	}
}